import java.util.*;

public class TestVisitor {

    static Vector<Visitor> v = new Vector<Visitor>(10);

    static String s = null;

    static void show() {
	Iterator<Visitor> itr = v.iterator();
	while ( itr.hasNext() ) System.out.print ( itr.next().name + "  " );
	System.out.println();
    }

    static boolean isIn() {
	Iterator<Visitor> itr = v.iterator();
	Visitor nv = new Visitor(s);
	while ( itr.hasNext() )
	    if ( itr.next().equals( nv ) ) return true;
	return false;
    }

    static void add() {
	s = ScreenIO.promptForString("Enter a visitor name: ");
	Visitor nv = new Visitor( s ) ;

	System.out.printf("Does vector contain %s ?  %s\n", s, v.contains(nv) ); 
	System.out.printf("Is %s in vector ?  %s\n", s, isIn()  ); 
	if ( ! v.contains( nv ) ) v.add(nv);
    }

    static void remove () {
	s = ScreenIO.promptForString("Enter a visitor name: ");
	Visitor nv = new Visitor( s ) ;
	System.out.printf("Does vector contain %s ?  %s\n", s, v.contains(nv) ); 
	v.remove (nv);
    }

    public static void main( String ags[]) {

	char		choice;
	while ( true ) {

	    choice = ScreenIO.promptForChar("Enteer L(ist), A(dd), R(emove) : ");

	    switch ( choice ) {

		case 'L': case 'l' : show(); break;
		case 'A': case 'a': add(); break;
		case 'R': case 'r': remove(); break;
	    }
	}
    }
}
